/**
 * 权限相关的数据
 * Created by gcc on 2017/9/29.
 */

import Vue from "vue";
import  { Tooltip } from 'view-design'

// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};

//页面状态相关
let status = {
  modalAddEdit :{
    isShow :false,
    isOnlyShow: false,
    isLoading: false,
    title:""
  },
  modalDelete :{
    isShow :false,
    content:""
  },

  rules: {
    ruleUnReceived: {
      result:[
        { required: true, type: 'integer', message: '请选择处理方式！', trigger: 'change' },
      ],
      refundAmount: [
      ],
    },
  },
};

// 和网络交互相关的参数
let params = {
  //搜索条件
  searchParams:{
    keyword: '',
  },
  changeStateParams:{
    refundId: '',
    state:'',
  },
  searchKeyword:{
    id:"",
    keyword:"",
    automatedWord:"",//输入的 联想词
    automatedWords:[

    ],
    isFuzzy:false,
    synonym:''
  },
  deleteKeyword:{
    id:"",
    keyword:""
  }
};

// 页面的数据源
let data = {
  searchKeywordList: [],
};

let tableTitles = function (self) {
  let titles =  [
     {
      type: 'index',
      title: '#',
      key: 'index',
      fixed: 'left',
      align: 'center',
      width: 65
    },
     {
      title: '关键字',
      key: 'keyword',
      align: 'center',
      width: 220,
    },
    {
      title: '替换词',
      key: 'synonym',
      align: 'center',
      width: 200,
    },
     {
      title: '联想词',
      key: 'automatedWords',
      align: 'center',
       render: (h, params) => {
        var html = [];
         let automatedWords = self.$toJson(params.row.automatedWords)
         if (automatedWords != null ){
           automatedWords.forEach(function (item) {
              html.push(h('Tag',item));
            });
         }
         return h('div',html);
       }
    },
     {
      title: '是否支持模糊查询',
      key: 'isFuzzy',
      align: 'center',
      width: 150,
     render: (h, params) => {
       return h('div', params.row.isFuzzy == true ? "是": "否");
     }
    },
     {
      title: '创建时间',
      key: 'createtime',
      align: 'center',
      width: 150,
      render: (h, params) => {
        return h('div', self.$tiyBJTime(params.row.createTime));
      }
    },
    {
      title: '操作',
      fixed: 'right',
      align: 'center',
      width: 150,
      render: (h, params) => {
        return h('div', [
          !self.$authority("OTHER-7-201")? h('div',""):h('Button', {
            props: {type: 'info', size: 'small'},
            style: {marginRight: '10px'},
            on: {
              click: () => {
                self.modifyKeyword(params.index)
              }
            }
          },"编辑"),
          !self.$authority("OTHER-7-202")? h('div',""):h('Button', {
            props: {type: 'info', size: 'small',},
            style: {marginRight: '10px'},
            on: {
              click: () => {
                self.deleteKeyword(params.index)
              }
            }
          }, '删除'),
        ]);
      }
    }
  ]
  return self.$authTableTitles(titles);
};


export default  {
  tPage: page,
  tStatus: status,
  tParams: params,
  tableTitles:tableTitles,
  tData: data
};
